package fr.insta.psape.service;

public class FactoryService {
    
    public FactoryService() {
    }
    
    public static IService<?> getService(Object objet) {

        String className = "fr.insta.psape.service" + objet.getClass().getSimpleName();

        Class<?> cl;
        Object o = null;

        try {
            cl = Class.forName(className);
            o = cl.newInstance();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();

        }
        return (IService<?>) o;
    }
    public static IService<?> getService(String classe) {

        String className = "fr.insta.psape.service"+classe;

        Class<?> cl;
        Object o = null;

        try {
            cl = Class.forName(className);
            o = cl.newInstance();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();

        }
        return (IService<?>) o;
    }
}
